package com.mllweb.blog.core.notice.email.template;

import java.io.*;

public interface EmailTemplate {



    void config(String key, String value);


    String subject();

    String contentType();


     String body() ;

    default String readTemplate(String template) {
        String text = "";
        FileInputStream inputStream = null;
        try {
            inputStream = new FileInputStream(new File(getClass().getResource("/").getPath() + "template/" + template + ".html"));
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            int b;
            while ((b = inputStream.read()) != -1) {
                byteArrayOutputStream.write(b);
            }
            text = byteArrayOutputStream.toString();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return text;
    }

}
